package com.cn.data.thread;

/**
 * @Author: chenl
 * @Date: 2019/2/17 22:40
 */
public class JoinDemo extends Thread {

    int i;
    Thread previousThread;

    //上一个线程
    public JoinDemo(Thread previousThread, int i) {
        this.previousThread = previousThread;
        this.i = i;
    }


    @Override
    public void run() {
        try {
//            System.out.println(previousThread.getName());
            this.previousThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("num : " + this.i);
    }

    public static void main(String[] args) throws InterruptedException {
//        Thread previousThread = Thread.currentThread();
//        for (int i = 0; i < 10; i++) {
//            JoinDemo joinDemo = new JoinDemo(previousThread, i);
//            joinDemo.start();
//            previousThread = joinDemo;
//        }

        int h;
        String key = "1";

        h = key.hashCode();
        System.out.println(h);
        System.out.println( h ^ (h >>> 16));

    }
}